﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PM.Web.Modules
{
    public partial class WebSite_Head : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindData();
            }
        }

        public string GetDisplayOrHide(object css)
        {
            string re = "display:none";
            if (css.ToString() == "sjy")
            {
                re = "";
            }
            return re;
        }

        public string GetClickEvent(object table,object id,object name)
        {
            string reUrl = "javascript:void(0)";
            switch (Convert.ToString(table))
            {
                case "face_m_website_i_bigclass":
                    reUrl = "I.aspx?bid=" + id.ToString();
                    break;
                case "face_m_website_news_class":
                    reUrl = "NewsClass.aspx?id=" + id.ToString();
                    break;
                case "face_m_website_com_introduce":
                    reUrl = "Introduce.aspx?id="+id.ToString();
                    break;
                case "face_m_gov_account":
                    reUrl = "GovNewsList.aspx?gid=" + id.ToString();
                    break;
                case "face_m_website_chamber_icon":
                    switch (name.ToString())
                    {
                        case "社区通知":
                        case "服务报告":
                        case "活动召集":
                            reUrl = "TopicList.aspx?cid=1&typename=" + name.ToString();
                            break;
                        case "社区议题":
                        case "业主大会":
                        case "维修基金":
                            reUrl = "TopicList.aspx?cid=2&typename=" + name.ToString();
                            break;
                        case "请修":
                            reUrl = "ServicesList.aspx?type=1";
                            break;
                        case "投诉":
                            reUrl = "ServicesList.aspx?type=2";
                            break;
                        case "费用查询":
                            reUrl = "FeeQuery.aspx";
                            break;
                        case "自助抄表":
                            reUrl = "MeterData.aspx";
                            break;
                        case "公共通讯录":
                            reUrl = "Commbook.aspx";
                            break;
                    }

                    break;
            }
            return "window.location.href='" + reUrl + "'";
        }

        private void bindData()
        {
            System.Data.DataTable dt;
            //if (Cache["PageHeadTable"] != null)
            //{
            //    dt = (System.Data.DataTable)(Cache["PageHeadTable"]);
            //}
            //else
            //{
            //    DataAccess.PmData dal = new DataAccess.PmData();
            //    dt = dal.GetSystemIcon(Common.GetCommunityCode(), string.Empty);
            //    Cache["PageHeadTable"] = dt;
            //}
            DataAccess.PmData dal = new DataAccess.PmData();
            dt = dal.GetSystemIcon(Common.GetCommunityCode(), string.Empty);
            this.repHead.DataSource = dt;
            this.repHead.DataBind();
        }
    }
}